<template>
  <div class="deviceInfos mescroll-touch">
    <div ref="nav" class="componentTopInv">
      <iu-header>
        <template #left>
          <x-icon
            @click="back"
            type="ios-arrow-back"
            size="21"
            fill="#fff"
          ></x-icon>
          <span>设备详情</span>
        </template>
        <template #right>
          <div v-focusable><iconSvg
            name="home"
            w="20px"
            h="22px"
            class="right_icon"
            @click.native="backToHomepage"
          ></iconSvg></div>
        </template>
      </iu-header>
    </div>
    <div ref="topBox" class="top-box" :class="{ notMore: !isMore }">
      <div class="title">
        <span>
          {{ deviceInfo.name }}
        </span>
        <span class="tip" :class="'status' + deviceInfo.runStatus">
          {{ deviceStatus[deviceInfo.runStatus] }}
        </span>
      </div>
      <div class="weui_cell">
        <div class="text1">设备编码:</div>
        <div class="text2 weui_cell_primary">{{ deviceInfo.code }}</div>
      </div>
      <div class="weui_cell">
        <div class="text1">所属区域:</div>
        <div class="text2 weui_cell_primary">
          {{ deviceInfo.departmentName }}
        </div>
      </div>
      <!-- <div class="weui_cell">
        <div class="text1">巡检周期:</div>
        <div class="text2 weui_cell_primary">
          {{ deviceInfo.checkCycle | checkCycle }}
        </div>
      </div> -->
      <div class="weui_cell">
        <div class="text1">开机时间:</div>
        <div class="text2 weui_cell_primary">
          {{ deviceInfo.trunOnTime | formatDate }}
        </div>
      </div>
      <div class="weui_cell">
        <div class="text1">停机时间:</div>
        <div class="text2 weui_cell_primary">
          {{ deviceInfo.shutDownTime | formatDate }}
        </div>
      </div>
      <div class="weui_cell">
        <div
          class="text1"
          v-if="deviceInfo.runStatus === 1 || deviceInfo.runStatus === 2"
        >
          运转时长:
        </div>
        <div class="text1" v-else-if="deviceInfo.runStatus === 3">
          停机时长:
        </div>
        <div class="text1" v-else-if="deviceInfo.runStatus === 4">
          故障时长:
        </div>
        <div class="text1" v-else-if="deviceInfo.runStatus === 5">
          离线时长:
        </div>
        <div class="text2 weui_cell_primary">
          {{ deviceInfo.runDuration ? deviceInfo.runDuration + "h" : "" }}
        </div>
      </div>
      <!-- <div class="weui_cell">
          <div class="text1">设备状态:</div>
          <div class="text2 weui_cell_primary">
            <span v-if="deviceInfo.status == 1">正常</span>
            <span v-else-if="deviceInfo.status == 2">异常</span>
            <span v-else>-</span>
          </div>
        </div>
        <div class="weui_cell">
          <div class="text1">运转状态:</div>
          <div class="text2 weui_cell_primary">
            <span v-if="deviceInfo.runStatus == 1">未监控</span>
            <span v-else-if="deviceInfo.runStatus == 2">运转</span>
            <span v-else-if="deviceInfo.runStatus == 3">停止</span>
            <span v-else-if="deviceInfo.runStatus == 4">故障</span>
            <span v-else-if="deviceInfo.runStatus == 5">离线</span>
            <span v-else>-</span>
          </div>
        </div>
        <div class="line"></div>
        <div class="weui_cell" v-for="(item,index) of monitorDeviceList" :key="index">
          <div class="weui_cell_primary">
            <div class="text1">采集编号:</div>
            <div class="text3">{{item.monitorDeviceCode}}</div>
          </div>
          <div class="weui_cell_primary">
            <div class="text1">采集类型:</div>
            <div class="text3">{{item.monitorDeviceType|ruleText}}</div>
          </div>
        </div> -->
    </div>
    <div ref="topTab" class="top-tab top-tab-scroll-container">
      <div class="top-tab-scroll-wrapper" ref="tabScroll">
        <div class="weui_cell scroll-content">
          <div
            class="weui_cell_primary top-tab-item"
            :class="{ active1: tabIndex == 1 }"
            @click="onTab(1, $event.target)"
          >
            <div class="title">设备数据</div>
            <div class="line"></div>
          </div>
          <div
            class="weui_cell_primary top-tab-item"
            :class="{ active1: tabIndex == 6 }"
            @click="onTab(6, $event.target)"
          >
            <div class="title">
              <div>预警记录</div>
              <img v-show="!status4" src="@/assets/icon/suo-icon.png" />
            </div>
            <div class="line"></div>
          </div>
          <div
            class="weui_cell_primary top-tab-item"
            :class="{ active1: tabIndex == 2 }"
            @click="onTab(2, $event.target)"
          >
            <div class="title">
              <div>点巡检记录</div>
              <img v-show="!status1" src="@/assets/icon/suo-icon.png" />
            </div>
            <div class="line"></div>
          </div>
          <div
            class="weui_cell_primary top-tab-item"
            :class="{ active1: tabIndex == 3 }"
            @click="onTab(3, $event.target)"
          >
            <div class="title">
              <div>更换记录</div>
              <img v-show="!status2" src="@/assets/icon/suo-icon.png" />
            </div>
            <div class="line"></div>
          </div>
          <!-- <div
            class="weui_cell_primary top-tab-item"
            :class="{ active1: tabIndex == 4 }"
            @click="onTab(4, $event.target)"
          >
            <div class="title">
              <div>设备数据</div>
            </div>
            <div class="line"></div>
          </div> -->
          <div
            class="weui_cell_primary top-tab-item"
            v-show="status3"
            :class="{ active1: tabIndex == 5 }"
            @click="onTab(5, $event.target)"
          >
            <div class="title">
              <div>财务记录</div>
            </div>
            <div class="line"></div>
          </div>
        </div>
      </div>
      <div class="flex" v-if="tabIndex == 5">
        <div
          class="box"
          :class="{ active1: financeIndex == 1 }"
          @click="onFinance(1)"
        >
          设备财务记录
        </div>
        <div
          class="box"
          :class="{ active1: financeIndex == 2 }"
          @click="onFinance(2)"
        >
          财务统计数据
        </div>
      </div>
      <div
        class="flex"
        style="opacity: 0"
        v-if="tabIndex == 4 && deviceDataInfo.length == 0"
      >
        <div class="box"></div>
        <div class="box"></div>
      </div>
    </div>

    <div ref="contentBox" class="content-box">
      <div v-show="tabIndex == 1" class="device-data">
        <div class="wrapperContent">
          <chart-list :chart-list="chartList"></chart-list>
          <!-- <div
            class="showPie day-charts"
            v-if="startStopChart.dataCode"
            :class="{ show: startStopShow }"
          >
            <div class="show-title">
              <span>开停机时段</span>
              <div
                class="show-btn"
                v-if="startStopShow"
                @click="startStopShow = false"
              >
                <span>收起</span>
                <x-icon type="ios-arrow-down" size="18" fill="#fff"></x-icon>
              </div>
              <div
                class="show-btn"
                v-else-if="!startStopShow"
                @click="startStopShow = true"
              >
                <span>展开</span>
                <x-icon type="ios-arrow-up" size="18" fill="#fff"></x-icon>
              </div>
            </div>
            <div class="day-charts-area" v-show="startStopShow === true">
              <div class="day-charts-pagination">
                <span
                  class="pagination-item"
                  @click="paginationTime(-1, 'startStop')"
                >
                  <x-icon
                    type="ios-arrow-left"
                    size="24"
                    fill="#456DE6"
                  ></x-icon>
                </span>
                <span class="pagination-text">
                  {{ startStopStartTime && startStopStartTime.format("MM-DD") }}
                </span>
                <span
                  class="pagination-item"
                  @click="paginationTime(1, 'startStop')"
                >
                  <x-icon
                    type="ios-arrow-right"
                    size="24"
                    fill="#456DE6"
                  ></x-icon>
                </span>
              </div>

              <div class="day-charts-time">
                <div class="day-charts-tip">
                  <span class="run">
                    运转: {{ statusTime(1, startStopTimetData) }}
                  </span>
                  <span class="stop">
                    停止: {{ statusTime(0, startStopTimetData) }}
                  </span>
                  <span class="offline">
                    离线: {{ statusTime(null, startStopTimetData) }}
                  </span>
                </div>
                <div class="day-charts-body">
                  <div
                    class="day-charts-item"
                    v-for="(item, index) in startStopTimetData"
                    :class="{
                      run: item.dataValue === 1,
                      stop: item.dataValue === 0,
                      offline: item.dataValue === null
                    }"
                    :key="index"
                    :style="timePercentage(item.startTime, item.endTime)"
                  ></div>
                </div>
                <div class="day-charts-bottom">
                  <span>0点</span>
                  <span>24点</span>
                </div>
              </div>
              <div
                class="chart-area"
                id="startStopPieChart"
                ref="startStopPieChart"
              ></div>
              <div class="day-charts-history">
                <span @click="showDataHistoryDetail(startStopChart)">
                  历史记录
                </span>
              </div>
            </div>
          </div> -->
          <!-- <div
            class="showPie"
            v-if="faultDurationChart.dataCode"
            :class="{ show: faultDurationShow }"
          >
            <div class="show-title">
              <span>设备故障时段</span>
              <div
                class="show-btn"
                v-if="faultDurationShow"
                @click="faultDurationShow = false"
              >
                <span>收起</span>
                <x-icon type="ios-arrow-down" size="18" fill="#fff"></x-icon>
              </div>
              <div
                class="show-btn"
                v-else-if="!faultDurationShow"
                @click="faultDurationShow = true"
              >
                <span>展开</span>
                <x-icon type="ios-arrow-up" size="18" fill="#fff"></x-icon>
              </div>
            </div>
            <div class="day-charts-area" v-show="faultDurationShow === true">
              <div class="day-charts-pagination">
                <span
                  class="pagination-item"
                  @click="paginationTime(-1, 'faultDuration')"
                >
                  <x-icon
                    type="ios-arrow-left"
                    size="24"
                    fill="#456DE6"
                  ></x-icon>
                </span>
                <span class="pagination-text">
                  {{
                    faultDurationStartTime &&
                      faultDurationStartTime.format("MM-DD")
                  }}
                </span>
                <span
                  class="pagination-item"
                  @click="paginationTime(1, 'faultDuration')"
                >
                  <x-icon
                    type="ios-arrow-right"
                    size="24"
                    fill="#456DE6"
                  ></x-icon>
                </span>
              </div>
              <div class="day-charts-time">
                <div class="day-charts-tip">
                  <span class="run">
                    正常: {{ statusTime(0, faultDurationTimeData) }}
                  </span>
                  <span class="fault">
                    故障: {{ statusTime(1, faultDurationTimeData) }}
                  </span>
                  <span class="offline">
                    离线: {{ statusTime(null, faultDurationTimeData) }}
                  </span>
                </div>
                <div class="day-charts-body">
                  <div
                    class="day-charts-item"
                    v-for="(item, index) in faultDurationTimeData"
                    :class="{
                      run: item.dataValue === 0,
                      fault: item.dataValue === 1,
                      offline: item.dataValue === null
                    }"
                    :key="index"
                    :style="timePercentage(item.startTime, item.endTime)"
                  ></div>
                </div>
                <div class="day-charts-bottom">
                  <span>0点</span>
                  <span>24点</span>
                </div>
              </div>
              <div
                class="chart-area"
                id="faultDurationChart"
                ref="faultDurationChart"
              ></div>
              <div class="day-charts-history">
                <span @click="showDataHistoryDetail(faultDurationChart)">
                  历史记录
                </span>
              </div>
            </div>
          </div> -->
          <div v-if="!chartList.length" class="not-content">
            <img src="/static/img/zwlr-icon.png" />
            <div class="title">暂无数据</div>
          </div>
        </div>
      </div>
      <div v-show="tabIndex == 2" class="wrapper">
        <!-- <div class="showPie" :class="{ show: checkOverShow }">
          <div class="show-title">
            <span>点巡检统计</span>
            <x-icon
              @click="checkOverShow = false"
              v-if="checkOverShow"
              type="ios-arrow-down"
              size="26"
              fill="#fff"
            ></x-icon>
            <x-icon
              @click="checkOverShow = true"
              v-else-if="!checkOverShow"
              type="ios-arrow-up"
              size="26"
              fill="#fff"
            ></x-icon>
          </div>
          <div
            v-show="checkOverShow"
            id="checkOverChart"
            :style="{ width: '100%', height: '100%' }"
          ></div>
        </div> -->
        <div class="flex">
          <div
            class="box"
            :class="{ active1: pollingIndex == 1 }"
            @click="onPolling(1)"
          >
            设备点巡检
          </div>
          <div
            class="box"
            :class="{ active1: pollingIndex == 2 }"
            @click="onPolling(2)"
          >
            部件点巡检
          </div>
        </div>
        <div v-show="pollingIndex === 1">
          <div v-if="deviceDotCheck.length === 0" class="not-content">
            <img src="/static/img/zwlr-icon.png" />
            <div class="title">暂无数据</div>
          </div>
          <div v-show="deviceDotCheck.length > 0" class="mescroll-area">
            <mescroll-vue
              class="me_scroll"
              ref="mescroll1"
              :down="mescrollDown1"
              :up="mescrollUp1"
              @init="mescrollInit1"
            >
              <div
                class="card"
                :class="{ active1: isShow1 == index }"
                v-for="(item, index) in deviceDotCheck"
                :key="index"
                @click="deviceWorkSheetDetail(item, index)"
              >
                <div class="cardTitle ">
                  执行时间：{{ item.checkSubmitTime | formatDate }}
                </div>
                <div class="line"></div>
                <div class="cardBottom">
                  <div class="title">
                    执行人：<span>{{ item.operatorName }}</span>
                  </div>
                  <div class="weui_cell">
                    <div>结果：</div>
                    <div class="weui_cell_primary title">
                      {{ item.checkResultName }}
                    </div>
                  </div>
                </div>
              </div>
            </mescroll-vue>
          </div>
        </div>
        <div v-show="pollingIndex === 2">
          <div v-if="componentDotCheck.length == 0" class="not-content">
            <img src="/static/img/zwlr-icon.png" />
            <div class="title">暂无数据</div>
          </div>
          <div v-show="componentDotCheck.length > 0" class="mescroll-area">
            <mescroll-vue
              class="me_scroll"
              ref="mescroll2"
              :down="mescrollDown2"
              :up="mescrollUp2"
              @init="mescrollInit2"
            >
              <div
                class="card"
                :class="{ active1: isShow2 == index }"
                v-for="(item, index) in componentDotCheck"
                :key="index"
                @click="compWorkSheetDetail(item, index)"
              >
                <div class="cardTitle weui_cell" style="padding-bottom: 0">
                  <div>部件：</div>
                  <div class="weui_cell_primary title">
                    {{ item.componentName }}
                  </div>
                </div>
                <div class="cardTitle2">
                  执行时间：{{ item.checkSubmitTime | formatDate }}
                </div>
                <div class="line"></div>
                <div class="cardBottom">
                  <div class="title">
                    执行人：<span>{{ item.operatorName }}</span>
                  </div>
                  <div class="weui_cell">
                    <div>结果：</div>
                    <div class="weui_cell_primary title">
                      {{ switchcheckResult(item.checkResult) }}
                    </div>
                  </div>
                </div>
              </div>
            </mescroll-vue>
          </div>
        </div>
      </div>
      <!-- <div v-show="tabIndex==2 && pollingIndex == 2" class="wrapper">
        </div> -->
      <div v-show="tabIndex == 3" class="wrapper">
        <div class="flex">
          <div
            class="box"
            :class="{ active1: replaceIndex == 1 }"
            @click="onReplace(1)"
          >
            设备更换记录
          </div>
          <div
            class="box"
            :class="{ active1: replaceIndex == 2 }"
            @click="onReplace(2)"
          >
            部件更换记录
          </div>
        </div>
        <div v-show="replaceIndex === 1">
          <div v-if="deviceReplace.length == 0" class="not-content">
            <img src="/static/img/zwlr-icon.png" />
            <div class="title">暂无数据</div>
          </div>
          <div v-show="deviceReplace.length > 0" class="replace-area">
            <!-- <mescroll-vue
              class="me_scroll"
              ref="mescroll4"
              :down="mescrollDown4"
              :up="mescrollUp4"
              @init="mescrollInit4"
            > -->
            <div
              class="card replace-card"
              :class="{ active1: isShow3 == index }"
              v-for="(item, index) in deviceReplace"
              :key="index"
              @click="replaceRecordDetail(item, index)"
            >
              <div class="cardTitle weui_cell" style="padding-bottom: 0">
                <div class="cardTitle-label">设备</div>
                <div class="weui_cell_primary">{{ item.deviceName }}</div>
                <div
                  class="cardTitle-tip"
                  style="text-align: right;"
                  :class="'status' + item.status"
                >
                  {{ item.status | replaceStatusText }}
                </div>
              </div>
              <div class="cardBottom">
                <div class="cardBottom-item">
                  <div class="item-key">执 行 人：</div>
                  <div class="item-value">{{ item.operatorName }}</div>
                </div>
                <div class="cardBottom-item">
                  <div class="item-key">更换时间：</div>
                  <div class="item-value">
                    {{ item.updateTime | formatDate }}
                  </div>
                </div>
                <div class="cardBottom-item weui_cell">
                  <div class="item-key">更换状态：</div>
                  <div class="weui_cell_primary item-value item-handle">
                    <span>
                      <template v-if="item.status === 11">
                        提前
                        {{ item.advanceTime }}
                        <!-- {{diffTime(item)}} -->
                        天
                      </template>
                      <template v-else>
                        {{ item.status | replaceStatusText }}
                      </template>
                    </span>
                    <div class="handle-btn">
                      <span
                        class="btn"
                        @click.stop="replaceRecordDetail(item, index)"
                      >
                        详情
                      </span>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <div
              class="newpage_work_more"
              v-if="replacePage.showMore1"
              @click="upCallback4(replacePage.pageNum++)"
            >
              查看更多
            </div>
            <!-- </mescroll-vue> -->
          </div>
        </div>
        <div v-show="replaceIndex === 2">
          <div v-if="componentReplace.length == 0" class="not-content">
            <img src="/static/img/zwlr-icon.png" />
            <div class="title">暂无数据</div>
          </div>
          <div v-show="componentReplace.length > 0" class="replace-area">
            <!-- <mescroll-vue
              class="me_scroll"
              ref="mescroll5"
              :down="mescrollDown5"
              :up="mescrollUp5"
              @init="mescrollInit5"
            > -->
            <div
              class="card replace-card"
              :class="{ active1: isShow4 == index }"
              v-for="(item, index) in componentReplace"
              :key="index"
              @click="replaceRecordDetail(item, index)"
            >
              <div class="cardTitle weui_cell" style="padding-bottom: 0">
                <div class="cardTitle-label">部件</div>
                <div class="weui_cell_primary">{{ item.componentName }}</div>
                <div
                  class="cardTitle-tip"
                  style="text-align: right;"
                  :class="'status' + item.status"
                >
                  {{ item.status | replaceStatusText }}
                </div>
              </div>
              <div class="cardBottom">
                <div class="cardBottom-item">
                  <div class="item-key">执 行 人：</div>
                  <div class="item-value">{{ item.operatorName }}</div>
                </div>
                <div class="cardBottom-item">
                  <div class="item-key">更换时间：</div>
                  <div class="item-value">
                    {{ item.updateTime | formatDate }}
                  </div>
                </div>
                <div class="cardBottom-item weui_cell">
                  <div class="item-key">更换状态：</div>
                  <div class="weui_cell_primary item-value item-handle">
                    <span>
                      <template v-if="item.status === 11">
                        提前
                        {{ item.advanceTime }}
                        <!-- {{diffTime(item)}} -->
                        天
                      </template>
                      <template v-else>
                        {{ item.status | replaceStatusText }}
                      </template>
                    </span>
                    <div class="handle-btn">
                      <span
                        class="btn"
                        @click.stop="replaceRecordDetail(item, index)"
                      >
                        详情
                      </span>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <!-- </mescroll-vue> -->

            <div
              class="newpage_work_more"
              v-if="replacePage.showMore2"
              @click="upCallback5(replacePage.pageNum++)"
            >
              查看更多
            </div>
          </div>
        </div>
      </div>
      <!-- <div v-show="tabIndex == 4" class="wrapper">
        <div v-show="deviceDataInfo.length == 0" class="not-content">
          <img src="/static/img/zwlr-icon.png" class="img4" />
          <div class="title">暂无数据</div>
        </div>
        <div v-show="deviceDataInfo.length > 0">
          <div
            class="card device-data-grid"
            v-for="(data, index) in deviceDataInfo"
            :key="index"
            @click="showDataDetail(data)"
          >
            <div class="cardRunTitle">
              {{ data.dataName }}
              <span v-if="data.unitName">({{ data.unitName }})</span>
            </div>
            <div class="cardBottom">
              最新值：<span
                :class="{
                  warning: data.abnormalType == 'warning',
                  danger: data.abnormalType == 'danger'
                }"
                >{{ data.latestValue }}</span
              >
            </div>
            <div class="line" style="height: 1px"></div>
            <div v-if="data.updateTime" class="cardBottom">
              更新时间：{{ data.updateTime | formatDate }}
            </div>
            <div v-else class="cardBottom">更新时间：一分钟前</div>
          </div>
        </div>
      </div> -->
      <div v-show="tabIndex == 5 && financeIndex == 1" class="wrapper">
        <div v-show="financialTableData.length == 0" class="not-content">
          <img src="/static/img/zwlr-icon.png" class="img4" />
          <div class="title">暂无数据</div>
        </div>
        <mescroll-vue
          class="me_scroll finnanceBox"
          ref="mescroll6"
          :down="mescrollDown6"
          :up="mescrollUp6"
          @init="mescrollInit6"
        >
          <div
            class="financeCard"
            :class="{ active1: activeIndex == index }"
            @click="showdetails(item.recordId, index)"
            v-for="(item, index) in financialTableData"
            :key="index"
          >
            <div class="row">
              <div>
                <span>设备名称：</span><span>{{ item.deviceName }}</span>
              </div>
              <div
                class="btn"
                :class="{
                  green: item.type == 1,
                  blue: item.type == 2,
                  red: item.type == 3
                }"
              >
                {{
                  item.type == 1
                    ? "新购"
                    : item.type == 2
                    ? "维修"
                    : item.type == 3
                    ? "更换"
                    : ""
                }}
              </div>
            </div>
            <div class="row">
              <div>
                <span>部件名称：</span><span>{{ item.componentName }}</span>
              </div>
            </div>
            <div class="line"></div>
            <div class="bottom">
              <span style="text-align: left;padding-left: 11px;"
                >实际金额：¥ {{ item.actualAmount.toFixed(2) }}
                <div class="verLine"></div
              ></span>
              <span>提交时间：{{ item.time | filtterTime }}</span>
            </div>
          </div>
        </mescroll-vue>
      </div>
      <div v-show="tabIndex == 5 && financeIndex == 2" class="wrapper">
        <!-- <div v-show="deviceDataInfo.length==0" class="not-content">
              <img src="/static/img/zwlr-icon.png" class="img4">
              <div class="title">暂无数据</div>
            </div> -->
        <div class="financeTable">
          <table>
            <tr>
              <td style="width:20%">类型</td>
              <td style="width:60%">花费金额</td>
              <td style="width:20%">条数</td>
            </tr>
            <tr>
              <td>新购</td>
              <td>{{ newBuyPay }} 元</td>
              <td>{{ newBuyTotal }}条</td>
            </tr>
            <tr>
              <td>维修</td>
              <td>{{ maintainPay }}元</td>
              <td>{{ maintainTotal }}条</td>
            </tr>
            <tr>
              <td>更换</td>
              <td>{{ replacePay }} 元</td>
              <td>{{ replaceTotal }}条</td>
            </tr>
            <tr>
              <td>合计</td>
              <td>{{ totalPay }} 元</td>
              <td>{{ effectiveTotal }}条</td>
            </tr>
          </table>
        </div>
      </div>
      <div v-show="tabIndex == 6" class="wrapper">
        <div class="newpage_work_conent">
          <iu-card
            class="early-card"
            v-for="(item, index) in earlywarningData"
            :key="index"
            @click.native="earlywarningDetail(item)"
          >
            <template #title>
              <div
                class="early-card-title"
                :class="{
                  warning: item.alarmLevel === 3,
                  error: item.alarmLevel === 5
                }"
              >
                {{ item.alarmLevelName }}
              </div>
            </template>
            <template #tip>
              <div class="early-card-tip" :class="'status' + item.status">
                <span>
                  {{ earlywarningStatusData[+item.status] }}
                </span>
              </div>
            </template>
            <template #body>
              <div class="early-card-body">
                {{ item.content }}
              </div>
              <div class="early-card-department">
                {{ item.departmentName }}
              </div>
              <div class="early-card-bottom">
                {{ item.createTime | formatDate }}
              </div>
            </template>
          </iu-card>
          <div
            class="newpage_work_more"
            v-if="earlyPage.showMore"
            @click="getMoreEalywarningList"
          >
            查看更多
          </div>
          <div v-show="earlywarningData.length == 0" class="not-content">
            <img src="/static/img/zwlr-icon.png" class="img4" />
            <div class="title">暂无数据</div>
          </div>
        </div>
      </div>
      <p class="total_num_view" id="total_num_view">卡片不可操作</p>
    </div>
  </div>
</template>

<script>
import MescrollVue from "mescroll.js/mescroll.vue";
import BScroll from "better-scroll";
import DeviceDao from "../../daos/device_dao";
import iuHeader from "@/components/common/header/index";
import iuCard from "@/components/common/card/index";
import EarlywarningDao from "@/daos/earlywarning_dao";
import DataAnalysisDao from "@/daos/data_analysis_dao";

import dayjs from "dayjs";
import { Scroller, Checker, CheckerItem, Tab, TabItem } from "vux";
import ChartList from "@/components/common/chart_list/index";

let _this = null;

import { Privilege } from "@/mixin";
export default {
  name: "deviceInfos",
  data() {
    return {
      activeIndex: -1,
      financeIndex: 1,
      isAndriod: false,
      processingShow: true,
      faultDurationShow: true,
      frequencyShow: true,
      checkOverShow: true,
      startStopShow: true,
      status1: false,
      status2: false,
      status3: false,
      status4: false,
      isShow1: -1,
      isShow2: -1,
      isShow3: -1,
      isShow4: -1,
      //多选状态
      status: false,
      processingChartList: [],
      faultDurationStartTime: "",
      faultDurationEndTime: "",
      faultDurationChart: {},
      faultDurationStartData: {},
      faultDurationTimeData: [],
      faultDurationTimeDataStatue: [],
      faultDurationChartEle: null,
      startStopStartTime: "",
      startStopEndTime: "",
      startStopTimetData: [],
      startStopTimetDataStatue: [],
      startStopChart: {},
      startStopChartEle: null,
      deviceStatus: ["全部", "未监控", "运转", "停止", "故障", "离线"],

      cycleType: 0,
      deviceId: "",
      deviceDetail: {},
      show: false,
      checkList: [],
      toastShow: false,
      toastText: null,
      //edit by xu
      deviceMessage: {},
      deviceComponent: [],
      deviceDotCheck: [],
      componentDotCheck: [],
      //点巡检 默认为展示设备
      dotCheckDeviceComponent: true,
      //更换 默认为展示设备
      replaceDeviceComponent: true,
      show4: false,
      deviceReplace: [],
      componentReplace: [],
      sort1: false,
      sort2: false,
      sort3: false,
      sortType: "changeTime",
      nowselect1: "left",
      nowselect2: "left",
      deviceInfo: {},
      departmentName: "",
      monitorDeviceCode: "",
      monitorDeviceType: "",
      monitorDeviceList: "",
      runList: [],
      time: "",
      isMore: true,
      tabIndex: 1,
      pollingIndex: 1,
      replaceIndex: 1,
      mescroll1: null,
      mescrollDown1: {},
      mescrollUp1: {
        that: this,
        callback: this.upCallback1,
        page: {
          num: 0,
          size: 20
        },
        htmlNodata: '<p class="upwarp-nodata">-- 暂无更多的数据 --</p>',
        noMoreSize: 5,
        toTop: {
          src: "./static/mescroll-totop.png",
          offset: 1000
        },
        isBounce: true
      },
      mescroll2: null,
      mescrollDown2: {},
      mescrollUp2: {
        that: this,
        callback: this.upCallback2,
        page: {
          num: 0,
          size: 20
        },
        htmlNodata: '<p class="upwarp-nodata">-- 暂无更多的数据 --</p>',
        noMoreSize: 5,
        toTop: {
          src: "./static/mescroll-totop.png",
          offset: 1000
        },
        isBounce: true
      },
      mescroll3: null,
      mescrollDown3: {},
      mescrollUp3: {
        that: this,
        callback: this.getDeviceData,
        page: {
          num: 0,
          size: 20
        },
        htmlNodata: '<p class="upwarp-nodata">-- 暂无更多的数据 --</p>',
        noMoreSize: 5,
        toTop: {
          src: "./static/mescroll-totop.png",
          offset: 1000
        },
        isBounce: true
      },
      mescroll4: null,
      mescrollDown4: {},
      mescrollUp4: {
        that: this,
        callback: this.upCallback4,
        page: {
          num: 0,
          size: 20
        },
        htmlNodata: '<p class="upwarp-nodata">-- 暂无更多的数据 --</p>',
        noMoreSize: 5,
        toTop: {
          src: "./static/mescroll-totop.png",
          offset: 1000
        },
        isBounce: true
      },
      mescroll5: null,
      mescrollDown5: {},
      mescrollUp5: {
        that: this,
        callback: this.upCallback5,
        page: {
          num: 0,
          size: 20
        },
        htmlNodata: '<p class="upwarp-nodata">-- 暂无更多的数据 --</p>',
        noMoreSize: 5,
        toTop: {
          src: "./static/mescroll-totop.png",
          offset: 1000
        },
        isBounce: true,
        ruleTypeList: []
      },
      mescroll6: null,
      mescrollDown6: {},
      mescrollUp6: {
        that: this,
        callback: this.upCallback6,
        page: {
          num: 0,
          size: 20
        },
        htmlNodata: '<p class="upwarp-nodata">-- 暂无更多的数据 --</p>',
        noMoreSize: 5,
        toTop: {
          src: "./static/mescroll-totop.png",
          offset: 1000
        },
        isBounce: true
      },

      pieOption: {
        tooltip: {
          trigger: "item",
          formatter: params => {
            let hour = (params.value / 3600).toFixed(2);
            return `${params.name}：${hour}h`;
          }
        },
        legend: {
          top: "4%",
          textStyle: { color: "#fff" }
        },
        series: [
          {
            type: "pie",
            radius: ["50%", "70%"],
            avoidLabelOverlap: false,
            label: {
              show: false,
              position: "center"
            },
            labelLine: {
              show: false
            },
            data: []
          }
        ]
      },
      chartList: [],
      financialTableData: [],
      maintainPay: "", //维修花费 ,
      maintainTotal: "", //维修记录数 ,
      newBuyPay: "", //新购花费 ,
      newBuyTotal: "", //新购记录数 ,
      replacePay: "", //更换花费 ,
      replaceTotal: "", //更换记录数 ,
      effectiveTotal: "", //有效记录数 ,
      totalPay: "", // 总花费
      deviceDataInfo: [],
      searchForm: {
        operatorType: "",
        submitTime: [],
        status: ""
      },
      earlywarningData: [],
      alarmLevelData: ["", "信息", "", "警告", "", "事故"],
      earlywarningStatusData: [
        "",
        "待确认",
        "",
        "已确认",
        "",
        "误报",
        "",
        "",
        "",
        "已关闭"
      ],
      replacePage: {
        pageNum: 1,
        showMore1: true,
        showMore2: true,
        id: 0
      },
      earlyPage: {
        pageNum: 1,
        showMore: true,
        id: 0,
        departmentName: ""
      },
      tabScroll: null
    };
  },
  components: {
    BScroll,
    MescrollVue,
    Scroller,
    Checker,
    CheckerItem,
    ChartList,
    Tab,
    TabItem,
    iuHeader,
    iuCard
  },
  mixins: [Privilege],
  // watch: {
  //   $route (to, from) {
  //     // this.getPageType(to.name)
  //     this.upCallback6({num:1,size:20},this.mescroll6);
  //   },
  // },
  beforeRouteEnter(to, from, next) {
    next(vm => {
      vm.$refs.mescroll1 && vm.$refs.mescroll1.beforeRouteEnter();
      vm.$refs.mescroll2 && vm.$refs.mescroll2.beforeRouteEnter();
      vm.$refs.mescroll4 && vm.$refs.mescroll4.beforeRouteEnter();
      vm.$refs.mescroll5 && vm.$refs.mescroll5.beforeRouteEnter();
      vm.$refs.mescroll6 && vm.$refs.mescroll6.beforeRouteEnter();
      vm.isShow1 = -1;
      vm.isShow1 = -1;
      vm.isShow2 = -1;
      vm.isShow3 = -1;
      vm.isShow4 = -1;
      vm.activeIndex = -1;
    });
  },
  beforeRouteLeave(to, from, next) {
    this.$refs.mescroll1 && this.$refs.mescroll1.beforeRouteLeave();
    this.$refs.mescroll2 && this.$refs.mescroll2.beforeRouteLeave();
    this.$refs.mescroll4 && this.$refs.mescroll4.beforeRouteLeave();
    this.$refs.mescroll5 && this.$refs.mescroll5.beforeRouteLeave();
    this.$refs.mescroll6 && this.$refs.mescroll6.beforeRouteLeave();
    this.$vux.loading.hide();
    next();
  },
  activated() {
    if (this.earlyPage.id && this.tabIndex === 6) {
      this.getEarlywarningDetail(this.earlyPage.id);
    }
  },
  //返回首页的公共方法
  inject: ["backToHomepage"],
  computed: {
    user() {
      return this.$store.state.user;
    }
  },
  filters: {
    //设备类型过滤
    ruleText(val) {
      let type = "";
      _this.ruleTypeList.forEach(item => {
        if (item.indicator == val) {
          type = item.dataTypeName;
        }
      });
      return type;
    },
    filtterTime(val) {
      if (val) {
        return val.split(" ")[0];
      }
    },
    checkCycle(val) {
      if (!val || !val.length) {
        return "";
      }
      let cycle = val.map(e => e.cycle + "小时").join(" ");
      return cycle;
    },
    replaceStatusText(key) {
      let text = "";
      switch (key) {
        case 1:
          text = "未更换";
          break;
        case 3:
          text = "逾期未更换";
          break;
        case 5:
          text = "更换完成";
          break;
        case 7:
          text = "逾期完成";
          break;
        case 9:
          text = "无需更换";
          break;
        case 11:
          text = "提前更换";
          break;
        default:
          text = "未更换";
          break;
      }
      return text;
    }
  },
  created() {
    _this = this;
    this.isAndriod = this.isAndriodDevice();
  },
  mounted() {
    if (!this.user) {
      this.getUser();
    } else {
      this.init();
    }
  },
  methods: {
    init() {
      this.$nextTick(() => {
        if (!this.Scroll) {
          this.tabScroll = new BScroll(this.$refs.tabScroll, {
            click: true,
            scrollX: true,
            probeType: 0
          });
          // debugger
          if (this.$refs.mescroll1) {
            this.Scroll = new BScroll(this.$refs.mescroll1, {
              click: true,
              tap: true
            });
          }
          if (this.$refs.mescroll2) {
            this.Scroll = new BScroll(this.$refs.mescroll2, {
              click: true,
              tap: true
            });
          }
          // this.Scroll = new BScroll(this.$refs.mescroll3, {
          //   click: true,
          //   tap: true
          // })
          if (this.$refs.mescroll4) {
            this.Scroll = new BScroll(this.$refs.mescroll4, {
              click: true,
              tap: true
            });
          }
          if (this.$refs.mescroll5) {
            this.Scroll = new BScroll(this.$refs.mescroll5, {
              click: true,
              tap: true
            });
          }
          // this.Scroll = new BScroll(this.$refs.mescroll6, {
          //   click: true,
          //   tap: true
          // })
        }
      });
      // this.deviceDetail = JSON.parse(localStorage.getItem("deviceInfo"));
      this.deviceId = this.$route.query.deviceId;

      this.faultDurationStartTime = dayjs()
        .subtract(1, "day")
        .startOf("date");
      this.faultDurationEndTime = dayjs().startOf("date");
      this.startStopStartTime = dayjs()
        .subtract(1, "day")
        .startOf("date");
      this.startStopEndTime = dayjs().startOf("date");
      // this.getDeviceData();
      this.getDeviceInfo();
      // this.getDeviceStatistics();
      this.getEalywarningList();

      this.status1 = this.privilege("wechat_operaionManage", "查看点巡检记录");
      this.status2 = this.privilege("wechat_operaionManage", "查看更换记录");
      this.status3 = this.privilege("wechat_manage", "财务记录");
      this.status4 = this.privilege("wechat_earlywarning");
      // console.log(this.status1, this.status2, this.status3, this.status4);
      let h =
        this.$refs.nav.offsetHeight +
        this.$refs.topBox.offsetHeight +
        this.$refs.topTab.offsetHeight;
      this.$refs.contentBox.style.height = h
        ? `calc(100vh - ${h}px)`
        : "calc(100vh - 200px)";
    },
    getUser() {
      this.$http(this.$API.getUserInfo, {})
        .then(res => {
          if (res) {
            this.$store.commit("saveUser", res);
            this.init();
          }
        })
        .catch(e => {});
    },
    showdetails(id, index) {
      this.activeIndex = index;
      setTimeout(() => {
        this.$router.push({
          path: "/manage/deviceDetailManage/financeDetail",
          query: { recordId: id }
        });
      }, 200);
    },
    switchcheckResult(key) {
      switch (key) {
        case 1:
          return "正常";
          break;
        case 2:
          return "轻微故障";
          break;
        case 3:
          return "中度故障";
          break;
        case 4:
          return "重度故障";
          break;

        default:
          return "-";
          break;
      }
    },
    back() {
      this.$router.go(-1);
    },
    // 判断是否安卓手机
    isAndriodDevice() {
      var u = navigator.userAgent;
      var isAndroid = u.indexOf("Android") > -1 || u.indexOf("Adr") > -1;
      return isAndroid;
    },
    changeHome() {
      this.$router.push({ name: "manage" });
    },
    notCard() {
      // $('#total_num_view').fadeIn(200)
      // setTimeout(()=>{
      //   $("#total_num_view").fadeOut(200);
      // },1500)
    },
    //设备点巡检详情跳转
    deviceWorkSheetDetail: function(config, index) {
      this.isShow1 = index;
      this.isShow2 = -1;
      this.isShow3 = -1;
      this.isShow4 = -1;
      let _this = this;
      setTimeout(function() {
        _this.$router.push({
          name: `workSheetDetail`,
          query: {
            id: config.id,
            cate: "deviceRecord"
          }
        });
      }, 200);
    },
    //部件点巡检详情跳转
    compWorkSheetDetail: function(config, index) {
      console.log(config);
      this.isShow2 = index;
      this.isShow1 = -1;
      this.isShow3 = -1;
      this.isShow4 = -1;
      let _this = this;
      setTimeout(function() {
        _this.$router.push({
          name: `workSheetDetail`,
          query: {
            id: config.id,
            cate: "componentRecord"
          }
        });
      }, 200);
    },

    replaceRecordDetail(config, index) {
      this.isShow4 = index;
      this.isShow2 = -1;
      this.isShow3 = -1;
      this.isShow12 = -1;

      this.$router.push({
        name: "replaceDetail",
        query: {
          id: config.id
        }
      });
    },
    getTime(my_time) {
      var days = my_time / 1000 / 60 / 60 / 24;
      var daysRound = Math.floor(days);
      var hours = my_time / 1000 / 60 / 60 - 24 * daysRound;
      var hoursRound = Math.floor(hours);
      var minutes = my_time / 1000 / 60 - 24 * 60 * daysRound - 60 * hoursRound;
      var minutesRound = Math.floor(minutes);
      var seconds =
        my_time / 1000 -
        24 * 60 * 60 * daysRound -
        60 * 60 * hoursRound -
        60 * minutesRound;
      // console.log('转换时间:', daysRound + '天', hoursRound + '时', minutesRound + '分', seconds.toFixed(0) + '秒');
      if (daysRound > 0) {
        var time =
          daysRound +
          "天" +
          hoursRound +
          "时" +
          minutesRound +
          "分" +
          seconds.toFixed(0) +
          "秒";
      } else if (hoursRound > 0) {
        var time =
          hoursRound + "时" + minutesRound + "分" + seconds.toFixed(0) + "秒";
      } else if (minutesRound > 0) {
        var time = minutesRound + "分" + seconds.toFixed(0) + "秒";
      } else if (seconds >= 0) {
        var time = seconds.toFixed(0) + "秒";
      }
      return time;
    },
    //更多高度处理
    onMore() {
      this.$nextTick(e => {
        let h =
          this.$refs.nav.offsetHeight +
          this.$refs.topBox.offsetHeight +
          this.$refs.topTab.offsetHeight;
        this.$refs.contentBox.style.height = h
          ? `calc(100vh - ${h}px)`
          : "calc(100vh - 200px)";
      });
    },
    //一级tab
    onTab(val, target) {
      if (val == 2 && !this.status1) {
        this.$commom.alert("您暂无此功能权限，请联系销售开通。", "提示", {
          confirmButtonText: "确定",
          callback: action => {}
        });
        return;
      }
      if (val == 3 && !this.status2) {
        this.$commom.alert("您暂无此功能权限，请联系销售开通。", "提示", {
          confirmButtonText: "确定",
          callback: action => {}
        });
        return;
      }
      if (val == 5 && !this.status3) {
        this.$commom.alert("您暂无此功能权限，请联系销售开通。", "提示", {
          confirmButtonText: "确定",
          callback: action => {}
        });
        return;
      }
      if (val == 6 && !this.status4) {
        this.$commom.alert("您暂无此功能权限，请联系销售开通。", "提示", {
          confirmButtonText: "确定",
          callback: action => {}
        });
        return;
      }
      if (val == 4) {
        this.getDeviceData();
      }
      if (target) {
        this.tabScroll.scrollToElement(target, 300, true, 0);
      }
      this.tabIndex = val;
      this.onMore();
    },
    //二级tab-巡检切换
    onPolling(val) {
      this.pollingIndex = val;
    },
    //二级tab-更换记录切换
    onReplace(val) {
      this.replaceIndex = val;
      this.replacePage.pageNum = 1;
      if (this.replaceIndex === 1) {
        this.upCallback4();
      } else {
        this.upCallback5();
      }
    },
    //二级tab-财务记录切换
    onFinance(val) {
      this.financeIndex = val;
    },
    mescrollInit1(mescroll) {
      this.mescroll1 = mescroll;
    },
    mescrollInit2(mescroll) {
      this.mescroll2 = mescroll;
    },
    mescrollInit3(mescroll) {
      this.mescroll3 = mescroll;
    },
    mescrollInit4(mescroll) {
      this.mescroll4 = mescroll;
    },
    mescrollInit5(mescroll) {
      this.mescroll5 = mescroll;
    },
    mescrollInit6(mescroll) {
      this.mescroll6 = mescroll;
    },
    //设备点巡检
    upCallback1(page, mescroll) {
      this.$vux.loading.show();
      let departmentId = "";
      if (this.deviceInfo) {
        departmentId = this.deviceInfo.departmentId;
      }
      let params = {
        deviceId: this.deviceId,
        departmentId: departmentId,
        checkTypeList: 2,
        statusList: [7, 9],
        pageNum: page.num,
        pageSize: page.size
      };
      this.$http(this.$API.getCheckList, params, true).then(res => {
        if (res) {
          this.$vux.loading.hide();
          let data = res.content;
          console.log(res.content);
          if (data === null || data === undefined) {
            this.deviceDotCheck = [];
            console.log(this.deviceDotCheck.length + "长度");
          } else {
            if (page.num === 1) {
              this.deviceDotCheck = [];
            }
            this.deviceDotCheck = this.deviceDotCheck.concat(data);
            this.$nextTick(() => {
              mescroll.endSuccess(data.length);
            });
          }
        } else {
          this.mescroll1.endErr();
        }
      });
    },
    //部件点巡检
    upCallback2(page, mescroll) {
      let departmentId = "";
      if (this.deviceInfo) {
        departmentId = this.deviceInfo.departmentId;
      }
      let params = {
        deviceId: this.deviceId,
        departmentId: departmentId,
        checkTypeList: 3,
        statusList: [7, 9],
        pageNum: page.num,
        pageSize: page.size
      };
      this.$http(this.$API.getCheckList, params, true).then(res => {
        if (res) {
          let data = res.content;
          if (data === null || data === undefined) {
            this.componentDotCheck = [];
          } else {
            if (page.num === 1) {
              this.componentDotCheck = [];
            }
            this.componentDotCheck = this.componentDotCheck.concat(data);
            this.$nextTick(() => {
              mescroll.endSuccess(data.length);
            });
          }
        } else {
          this.mescroll2.endErr();
        }
      });
    },
    //运转记录
    upCallback3(page, mescroll) {
      if (!this.deviceInfo.code) {
        return;
      }
      let params = {
        deviceCode: this.deviceInfo.code,
        pageNum: page.num,
        pageSize: page.size
      };
      this.$http(this.$API.getRunList, params, true).then(res => {
        if (res) {
          let data = res;
          data.forEach(item => {
            item.durationRespDTO = this.getTime(item.durationRespDTO.millis);
          });
          if (page.num === 1) {
            this.runList = [];
          }
          this.runList = this.runList.concat(data);
          this.$nextTick(() => {
            mescroll.endSuccess(data.length);
          });
        } else {
          this.mescroll3.endErr();
        }
      });
    },
    //设备数据
    getDeviceData: function() {
      DeviceDao.loadDeviceData(this.deviceId, data => {
        if (data) {
          this.deviceDataInfo = data;
        }
      });
    },
    //设备更换记录
    upCallback4(page, mescroll) {
      if (!this.deviceInfo.departmentId) {
        return;
      }
      let params = {
        deviceId: this.deviceId,
        departmentId: this.deviceInfo.departmentId,
        pageNum: this.replacePage.pageNum,
        pageSize: 10,
        viewType: 2,
        replaceType: 1
      };
      this.getReplaceTaskRecordDepartmentDetails(params, mescroll);

      // this.$http(this.$API.loadDeviceAllReplaceRecord, params, true).then(
      //   res => {
      //     if (res) {
      //       let data = res;
      //       if (page.num === 1) {
      //         this.deviceReplace = [];
      //       }
      //       this.deviceReplace = this.deviceReplace.concat(data);
      //       this.$nextTick(() => {
      //         mescroll.endSuccess(data.length);
      //       });
      //     } else {
      //       this.mescroll4.endErr();
      //     }
      //   }
      // );
    },
    //部件更换记录
    upCallback5(page, mescroll) {
      if (!this.deviceInfo.departmentId) {
        return;
      }
      let params = {
        deviceId: this.deviceId,
        departmentId: this.deviceInfo.departmentId,
        pageNum: this.replacePage.pageNum,
        pageSize: 10,
        viewType: 2,
        replaceType: 2
      };
      this.getReplaceTaskRecordDepartmentDetails(params, mescroll);
      // this.$http(this.$API.loadCompReplaceRecord, params, true).then(res => {
      //   if (res) {
      //     let data = res;
      //     if (page.num === 1) {
      //       this.componentReplace = [];
      //     }
      //     this.componentReplace = this.componentReplace.concat(data);
      //     this.$nextTick(() => {
      //       mescroll.endSuccess(data.length);
      //     });
      //   } else {
      //     this.mescroll4.endErr();
      //   }
      // });
    },
    getReplaceTaskRecordDepartmentDetails(params) {
      // console.log(item);
      DeviceDao.getReplaceTaskRecordDepartmentDetails(params, res => {
        if (res) {
          let data = res.content;
          if (params.replaceType === 1) {
            if (params.pageNum === 1) {
              this.deviceReplace.splice(0);
            }
            this.deviceReplace.push(...data);
            if (
              !res.totalPages ||
              this.replacePage.pageNum === res.totalPages
            ) {
              this.replacePage.showMore1 = false;
            }
          } else {
            if (params.pageNum === 1) {
              this.componentReplace.splice(0);
            }
            if (
              !res.totalPages ||
              this.replacePage.pageNum === res.totalPages
            ) {
              this.replacePage.showMore2 = false;
            }
            this.componentReplace.push(...data);
          }
          // this.$nextTick(() => {
          //   mescroll.endSuccess(data.length);
          // });
        } else {
          // mescroll.endErr();
        }
      });
    },
    //设备财务记录
    upCallback6(page, mescroll) {
      // let departmentId = "";
      // if (this.deviceInfo) {
      //   departmentId = this.deviceInfo.departmentId;
      // }
      // let params = {
      //   componentId: null,
      //   departmentId: departmentId,
      //   deviceId: this.deviceId,
      //   pageNo: page.num,
      //   pageSize: page.size,
      //   status: this.searchForm.status,
      //   times: this.searchForm.submitTime,
      //   type: this.searchForm.operatorType
      // };
      // DeviceDao.getFinacialList(params, res => {
      //   if (res) {
      //     if (page.num === 1) {
      //       this.financialTableData = [];
      //     }

      //     this.financialTableData = this.financialTableData.concat(res.record);
      //     this.maintainPay = res.maintainPay; //维修花费 ,
      //     this.maintainTotal = res.maintainTotal; //维修记录数 ,
      //     this.newBuyPay = res.newBuyPay; //新购花费 ,
      //     this.newBuyTotal = res.newBuyTotal; //新购记录数 ,
      //     this.replacePay = res.replacePay; //更换花费 ,
      //     this.replaceTotal = res.replaceTotal; //更换记录数 ,
      //     this.effectiveTotal = res.effectiveTotal; //有效记录数 ,
      //     this.totalPay = res.totalPay; // 总花费
      //     this.$nextTick(() => {
      //       mescroll.endByPage(res.record.length, res.total);
      //       // mescroll.endSuccess(res.record.length);
      //     });
      //   } else {
      //     mescroll.endErr();
      //   }
      // });
      mescroll.endByPage(0, 0);
    },
    // 获取设备信息
    getDeviceInfo() {
      DeviceDao.getDeviceInfo(this.deviceId, res => {
        this.deviceInfo = res;
        this.departmentName =
          this.deviceInfo.departmentName || this.deviceInfo.department_name;
        // 获取图表
        this.getChartConfig();
        this.$nextTick(e => {
          let page = {
            num: 1,
            size: 20
          };
          this.upCallback4(page);
          this.upCallback5(page);
        });
      });
    },
    statusTime(status, target) {
      let res = target.filter(e => e.dataValue === status);
      let time = res.reduce((acc, cur) => {
        let res = 0;
        if (cur.endTime && cur.startTime) {
          res = Number.parseInt(cur.endTime / 1000 - cur.startTime / 1000);
        }
        return acc + res;
      }, 0);
      // console.log(time);
      // let mm = Number.parseInt(time / 60);
      // let ss = Number.parseInt(time % 60);
      let hh = (time / 3600).toFixed(2);
      return hh + "h";
    },
    timePercentage(startTime, endTime) {
      let start = dayjs(startTime || dayjs()),
        end = dayjs(endTime || start);
      let width = (end.diff(start) / (24 * 3600 * 1000)) * 100;

      let left =
        ((start.hour() * 3600 * 1000 +
          start.minute() * 60 * 1000 +
          start.second() * 1000 +
          start.millisecond()) /
          (24 * 3600 * 1000)) *
        100;
      return { width: width.toFixed(3) + "%", left: left.toFixed(3) + "%" };
    },
    setProcessingChart(index) {
      // console.log(index);
      let title = this.processingChartList[index].dataName;
      if (!this.processingChartList[index].chart) {
        let option = {
          color: ["#F94B48", "#F9D64A", "#54CA75", "#456DE5"],
          grid: {
            containLabel: true,
            top: "18%",
            bottom: "10%",
            left: "4%",
            right: "4%"
          },
          tooltip: {
            trigger: "axis",
            formatter: params => {
              let text = `${params[0].axisValue} <br />`;
              params.forEach((e, index) => {
                text += `${e.seriesName}-${title}：${
                  e.value[index + 1]
                } <br />`;
              });
              return text;
            }
          },
          legend: { top: "4%", textStyle: { color: "#fff" } },
          textStyle: {
            color: "#959595"
          },
          xAxis: {
            type: "category",
            axisLine: {
              lineStyle: {
                color: "#979797"
              }
            },
            axisTick: {
              show: false
            }
          },
          yAxis: {
            type: "value",
            axisLine: {
              show: false
            },
            axisTick: {
              show: false
            },
            splitLine: {
              lineStyle: {
                color: "#979797",
                type: "dotted"
              }
            }
          }
        };

        this.processingChartList[index].chart = this.$echarts.init(
          this.$refs.processingChart[index]
        );
        this.processingChartList[index].chart.setOption(option);
      }
      let source = this.formatterProcessingDataset(
        this.processingChartList[index].chartData
      );
      let series = this.formatterProcessingSeries(
        this.processingChartList[index].chartData
      );
      // console.log(source, series);
      this.processingChartList[index].chart.setOption({
        dataset: {
          source
        },
        series
      });
      let option = this.processingChartList[index].chart.getOption();
      if (!source.length) {
        option.graphic = [
          {
            type: "text",
            left: "center",
            top: "40%",
            style: {
              text: "暂无数据",
              fill: "#fff",
              fontSize: 18
            }
          }
        ];
        this.processingChartList[index].chart.setOption(option, true);
      } else {
        option.graphic = [];
        this.processingChartList[index].chart.setOption(option, true);
      }
    },
    setfaultDurationChart(res) {
      let list = [
        {
          value: 0,
          name: "",
          dataValue: 0,
          itemStyle: { color: "#456DE5" }
        },
        {
          value: 0,
          name: "",
          dataValue: 1,
          itemStyle: { color: "#DD6031" }
        },
        {
          value: 0,
          name: "",
          dataValue: null,
          itemStyle: { color: "#D2D2D2" }
        }
      ];
      res.forEach(e => {
        list.forEach(ele => {
          if (ele.dataValue === e.dataValue) {
            ele.value += +e.value;
            ele.name = e.name;
          }
        });
      });
      // console.log(list);
      let data = list.filter(e => e.value);

      // console.log(data);
      if (!this.faultDurationChartEle) {
        this.faultDurationChartEle = this.$echarts.init(
          this.$refs.faultDurationChart
        );
        this.faultDurationChartEle.setOption(this.pieOption);
      }
      let option = this.faultDurationChartEle.getOption();
      if (!data.length) {
        option.graphic = [
          {
            type: "text",
            left: "center",
            top: "40%",
            style: {
              text: "暂无数据",
              fill: "#fff",
              fontSize: 18
            }
          }
        ];
        this.faultDurationChartEle.setOption(option);
      } else {
        option.graphic = [];
        this.faultDurationChartEle.setOption(option, true);
      }
      this.faultDurationChartEle.setOption({
        series: [
          {
            data: data
          }
        ]
      });
    },
    setStartStopPicChart(res) {
      let list = [
        {
          value: 0,
          name: "",
          dataValue: 1,
          itemStyle: { color: "#456DE5" }
        },
        {
          value: 0,
          name: "",
          dataValue: 0,
          itemStyle: { color: "#DC9610" }
        },
        {
          value: 0,
          name: "",
          dataValue: null,
          itemStyle: { color: "#D2D2D2" }
        }
      ];
      res.forEach(e => {
        list.forEach(ele => {
          if (ele.dataValue === e.dataValue) {
            ele.value += +e.value;
            ele.name = e.name;
          }
        });
      });

      let data = list.filter(e => e.value);

      if (!this.startStopPieData) {
        this.startStopPieDataEle = this.$echarts.init(
          this.$refs.startStopPieChart
        );
        this.startStopPieDataEle.setOption(this.pieOption);
      }
      let option = this.startStopPieDataEle.getOption();
      if (!data.length) {
        option.graphic = [
          {
            type: "text",
            left: "center",
            top: "40%",
            style: {
              text: "暂无数据",
              fill: "#fff",
              fontSize: 18
            }
          }
        ];
        this.startStopPieDataEle.setOption(option);
      } else {
        option.graphic = [];
        this.startStopPieDataEle.setOption(option, true);
      }
      this.startStopPieDataEle.setOption({
        series: [
          {
            data: data
          }
        ]
      });
    },
    getDeviceStatistics() {
      DeviceDao.getQueryChartList(this.deviceId, res => {
        if (res && res.length) {
          res.forEach(ele => {
            if (ele.dataName === "故障" && ele.chartType !== 1) {
              // 故障时间段
              this.faultDurationChart = ele;
              this.getFaultDurationChartDataDetail(ele.dataCode, ele.chartType);
            } else if (ele.dataName === "启停" && ele.chartType !== 1) {
              // 开停机时间段
              this.startStopChart = ele;
              this.getStartStopChartDataDetail(ele.dataCode, ele.chartType);
            } else if (
              ele.chartType === 1 &&
              ele.dataName !== "启停" &&
              ele.dataName !== "故障"
            ) {
              // 生产数据
              ele.startTime = dayjs().startOf("date");
              ele.endTime = dayjs()
                .add(1, "day")
                .startOf("date");
              ele.cycleType = 1;
              ele.show = true;
              ele.chart = null;
              ele.chartData = [];
              let i = this.processingChartList.length;
              this.processingChartList.push(ele);
              // this.getProcessingChartDataDetail(ele, i);
            }
          });
          this.chartList = res;
        }
      });
    },
    getProcessingChartDataDetail(item, index) {
      // 1:小时 2:日，周 3:月 4:年
      let cycleType = 1;
      if (item.cycleType === 2 || item.cycleType === 3) {
        cycleType = 2;
      } else if (item.cycleType === 4) {
        cycleType = 3;
      }
      let params = {
        dataCode: item.dataCode,
        chartType: item.chartType,
        cycleType,
        deviceId: this.deviceId,
        endTime: item.endTime.format(),
        startTime: item.startTime.format()
      };
      DeviceDao.getChartDataDetail(params, res => {
        // if (res && res.length) {
        this.$set(this.processingChartList[index], "chartData", res || []);
        // }
        // this.setProcessingChart(index);
      });
      this.$vux.loading.hide();
    },
    getFaultDurationChartDataDetail(dataCode = "", chartType = "") {
      let params = {
        dataCode,
        chartType,
        cycleType: 2,
        deviceId: this.deviceId,
        endTime: this.faultDurationEndTime.format(),
        startTime: this.faultDurationStartTime.format()
      };
      DeviceDao.getChartDataDetail(params, res => {
        if (chartType === 3) {
          this.setfaultDurationChart(res || []);
        } else if (chartType === 2) {
          this.faultDurationTimeData = res;
          this.faultDurationTimeDataStatue = Array.from(
            new Set(res.map(e => e.name))
          );
          this.faultDurationTimeDataStatue.sort().reverse();
        }
      });
      this.$vux.loading.hide();
    },
    getStartStopChartDataDetail(dataCode = "", chartType = "") {
      let params = {
        dataCode,
        chartType,
        cycleType: 2,
        deviceId: this.deviceId,
        endTime: this.startStopEndTime.format(),
        startTime: this.startStopStartTime.format()
      };
      DeviceDao.getChartDataDetail(params, res => {
        if (chartType === 3) {
          this.setStartStopPicChart(res || []);
        } else if (chartType === 2) {
          this.startStopTimetData = res;
          this.startStopTimetDataStatue = Array.from(
            new Set(res.map(e => e.name))
          );
          this.startStopTimetDataStatue.sort().reverse();
        }
      });
      this.$vux.loading.hide();
    },
    paginationTime(day, target, index = null) {
      if (index === null) {
        if (day > 0) {
          if (
            this[target + "StartTime"]
              .add(1, "day")
              .isAfter(dayjs().subtract(1, "day"))
          ) {
            this.$vux.toast.text("只能查看当天之前的数据");
            return;
          }
          this[target + "StartTime"] = this[target + "StartTime"].add(1, "day");
          this[target + "EndTime"] = this[target + "EndTime"].add(1, "day");
        } else {
          this[target + "StartTime"] = this[target + "StartTime"].subtract(
            1,
            "day"
          );
          this[target + "EndTime"] = this[target + "EndTime"].subtract(
            1,
            "day"
          );
        }
      } else {
        let type = "";
        switch (this.processingChartList[index].cycleType) {
          case 1:
            type = "day";
            break;
          case 2:
            type = "week";
            break;
          case 3:
            type = "month";
            break;
          case 4:
            type = "year";
            break;
          default:
            type = "day";
            break;
        }
        if (day > 0) {
          if (
            this.processingChartList[index].startTime
              .add(1, type)
              .isAfter(dayjs())
          ) {
            this.$vux.toast.text("只能查看当天之前的数据");
            return;
          }
          this.processingChartList[index].startTime = this.processingChartList[
            index
          ].startTime.add(1, type);
          this.processingChartList[index].endTime = this.processingChartList[
            index
          ].endTime.add(1, type);
        } else {
          this.processingChartList[index].startTime = this.processingChartList[
            index
          ].startTime.subtract(1, type);
          this.processingChartList[index].endTime = this.processingChartList[
            index
          ].endTime.subtract(1, type);
        }
      }
      // this.$vux.loading.show({
      //   text: "Loading"
      // });
      if (target === "faultDuration") {
        this.getFaultDurationChartDataDetail(
          this.faultDurationChart.dataCode,
          2
        );
        this.getFaultDurationChartDataDetail(
          this.faultDurationChart.dataCode,
          3
        );
      } else if (target === "startStop") {
        this.getStartStopChartDataDetail(this.startStopChart.dataCode, 2);
        this.getStartStopChartDataDetail(this.startStopChart.dataCode, 3);
      } else if (target === "processing") {
        this.getProcessingChartDataDetail(
          this.processingChartList[index],
          index
        );
      }
    },
    changeCycleType(value, item, index) {
      // console.log(item);
      item.cycleType = value;
      // this.processingChartList[index].cycleType = value
      if (value === 1) {
        item.startTime = dayjs().startOf("date");
        item.endTime = dayjs()
          .startOf("date")
          .add(1, "day");
      } else if (value === 2) {
        item.startTime = dayjs()
          .startOf("day")
          .subtract(1, "week")
          .add(1, "day");
        item.endTime = dayjs()
          .startOf("day")
          .add(1, "day");
      } else if (value === 3) {
        item.startTime = dayjs().startOf("month");
        item.endTime = dayjs()
          .startOf("month")
          .add(1, "month");
      } else if (value === 4) {
        item.startTime = dayjs().startOf("year");
        item.endTime = dayjs()
          .startOf("year")
          .add(1, "year");
      }
      this.getProcessingChartDataDetail(item, index);
    },
    formatterProcessingDataset(data) {
      let dataset = [],
        xAxis = [],
        yAxis = [];
      if (data && data.length) {
        xAxis.push("product");
        data.forEach(e => {
          xAxis.push(e.name);
          e.dataDetails.forEach((ele, index) => {
            if (!yAxis[index]) {
              yAxis.push([ele.time, ele.value]);
            } else {
              yAxis[index].push(ele.value);
            }
          });
        });
        dataset.push(xAxis, ...yAxis);
        return dataset;
      } else {
        return [];
      }
    },
    formatterProcessingSeries(data) {
      let series = [];
      if (data && data.length) {
        series = data.map(() => {
          return {
            type: "line"
          };
        });
      }
      // console.log(series, "series");
      return series;
    },
    showDataDetail(data) {
      _this.$router.push({
        name: "deviceDataDetail",
        query: {
          dataId: data.biMetaDataId,
          dataCode: data.dataCode,
          dataName: data.dataName,
          unitName: data.unitName
        }
      });
    },
    showDataHistoryDetail(item) {
      this.$router.push({
        name: "deviceDataDetail",
        query: {
          dataId: item.biMetaDateId,
          dataCode: item.dataCode,
          dataName: item.dataName,
          unitName: ""
        }
      });
    },
    getChartConfig() {
      let code = "SJ01";
      let params = {
        code,
        departmentId: this.deviceInfo.departmentId,
        deviceCode: this.deviceInfo.code
      };
      DataAnalysisDao.getChartConfig(params, res => {
        this.chartList.splice(0);
        if (res && res.length) {
          this.chartList = res.map(e => {
            e.show = 0;
            e.code = code;
            e.departmentId = this.deviceInfo.departmentId;
            return e;
          });
        }
      });
    },
    getMoreEalywarningList() {
      this.earlyPage.pageNum++;
      this.getEalywarningList();
    },
    getEalywarningList() {
      let params = {
        deviceId: this.deviceId,
        pageSize: 10,
        pageNum: this.earlyPage.pageNum
      };
      EarlywarningDao.getEarlywarningList(params, res => {
        if (this.earlyPage.pageNum === 1) {
          this.earlywarningData.splice(0);
        }
        if (res.content && res.content.length) {
          this.earlywarningData.push(...res.content);
        }
        if (!res.totalPages || this.earlyPage.pageNum === res.totalPages) {
          this.earlyPage.showMore = false;
        }
      });
    },
    getEarlywarningDetail(item) {
      EarlywarningDao.getEarlywarningDetail(id, res => {
        if (res) {
          const index = this.earlywarningData.findIndex(e => e.id === id);
          if (index !== -1) {
            this.$set(this.earlywarningData, index, res);
          }
        }
      });
    },
    earlywarningDetail(item) {
      this.earlyPage.id = item.id;
      this.earlyPage.departmentName = item.departmentName;
      this.$router.push({
        name: "earlywarningDetails",
        query: {
          id: item.id
        }
      });
    }
  }
};
</script>

<style lang="less" scoped>
* {
  -ms-touch-action: unset !important;
  touch-action: unset !important;
}
.financeCard {
  border-radius: 4px;
  background: #292a4d;
  margin-bottom: 12px;
  position: relative;
  transition: 0.2s all ease-in-out;
  color: #fff;
  margin: 7px 0px;
  font-size: 14px;
  padding: 15px 0px;
  &.active1 {
    background: #383a69;
  }
  .btn {
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 12px;
  }
  .green {
    background-color: #67c23a;
  }
  .blue {
    background-color: #409eff;
  }
  .red {
    background-color: #f56c6c;
  }
  .line {
    width: 100%;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 10px 0;
  }
  .row {
    display: flex;
    padding: 0px 10px;
    margin-bottom: 8px;
    justify-content: space-between;
  }
  .bottom {
    display: flex;
    justify-content: space-between;
    span {
      position: relative;
      display: inline-block;
      width: 50%;
      text-align: center;
    }
    .verLine {
      position: absolute;
      right: 1px;
      top: 0;
      width: 1px;
      height: 20px;
      background: rgba(255, 255, 255, 0.1);
    }
  }
}
.financeTable {
  padding: 0 10px;
  color: #fff;
  font-size: 12px;
  table {
    width: 100%;
    border-color: #fff;
    border-style: solid;
    border-width: 1px 0px 0px 1px;
    border-spacing: 0;
    line-height: 1.5;
  }
  tr {
    td {
      text-align: center;
      padding: 12px 0;
      border-bottom: 1px solid #fff;
      border-right: 1px solid #fff;
    }
  }
}
.deviceInfos {
  // position: fixed;
  color: #fff;
  width: 100%;
  min-height: 100vh;
  height: auto;
  background: #151624;
  .weui_cell_primary {
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    flex: 1;
  }
  .weui_cell {
    position: relative;
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
  }
  .changeMore {
    color: #fff;
    background: #1f2037;
    z-index: 110;
    // position: fixed;
    display: flex;
    width: 100%;
    height: 50px;
    padding: 0 !important;
    margin: 0 !important;
    /*margin-bottom: 5px !important;*/
    box-sizing: border-box;
    border-bottom: 1px solid #494a5f;
    div {
      flex: 1;
    }
    .left,
    .right {
      // float: left;
      // width: 49.7%;
      height: 100%;
      padding: 0 !important;
      margin: 0 !important;
      .scan {
        // float: left;
        // margin-left: 30%;
        margin-top: 11px;
        display: inline-block;
      }
      .backToHomepage {
        margin-top: 11px !important;
      }
    }
    .left {
      text-align: center;
    }
    .right {
      text-align: right;
      .scan {
        margin-right: 10px;
        &:nth-child(1) {
          position: relative;
          /*&::before{*/
          /*content: "";*/
          /*width: .026667rem;*/
          /*height: 30%;*/
          /*background: hsla(0,0%,100%,.4);*/
          /*position: absolute;*/
          /*top: calc(~'50% + 1px');*/
          /*left: -14px;*/
          /*-webkit-transform: translateY(-50%);*/
          /*transform: translateY(-50%);*/
          /*border-left: 0.026667rem solid rgba(255, 255, 255, 0.1);*/
          /*}*/
        }
      }
    }
    .navTitle {
      white-space: nowrap;
      display: flex;
      text-align: center;
      color: #ffffff;
      span {
        font-size: 16px;
        display: inline-block;
        height: 50px;
        line-height: 50px;
      }
      .icon {
        font-size: 20px;
        margin-left: 10px;
        display: inline-block;
        height: 50px;
        line-height: 50px;
        color: #ffffff;
      }
    }
    // .left {
    // width: 49.8% !important;
    // border-right: 1px solid #494a5f;
    // }
  }
  .total_num_view {
    position: absolute;
    bottom: 30%;
    left: 50%;
    -webkit-transform: translate(-50%);
    transform: translate(-50%);
    height: 1.173333rem;
    line-height: 1.173333rem;
    text-align: center;
    font-size: 0.373333rem;
    color: #333;
    width: 4.373333rem;
    background: hsla(0, 0%, 100%, 0.8);
    border-radius: 1.333333rem;
    display: none;
    z-index: 800;
  }
  .top {
    width: 100%;
    // position: fixed;
    left: 0;
    top: 0;
    font-size: 17px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: rgba(255, 255, 255, 1);
    height: 46px;
    background: #1f2037;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    .l-img {
      position: absolute;
      width: 22px;
      height: 22px;
      left: 11px;
    }
    .r-img {
      position: absolute;
      width: 34px;
      height: 34px;
      right: 16px;
    }
  }
  .top-box {
    height: auto;
    margin: 10px 16px;
    padding: 0 10px 2px;
    background: #1f2037;
    z-index: 10;
    border-radius: 4px;
    .title {
      font-size: 16px;
      color: #fff;
      padding: 6px 10px;
      margin: 0 -10px;
      background-color: #2b2c4f;
      display: flex;
      justify-content: space-between;
      .tip {
        position: relative;
        font-size: 14px;
        color: #fff;
        &::before {
          content: "";
          position: absolute;
          left: -12px;
          top: 7px;
          width: 8px;
          height: 8px;
          border-radius: 4px;
        }
        &.status1::before {
          background-color: gray;
        }
        &.status2::before {
          background-color: #456de5;
        }
        &.status3::before {
          background-color: #dc9610;
        }
        &.status4::before {
          background-color: #dd6031;
        }
        &.status5::before {
          background-color: #d2d2d2;
        }
      }
    }
    .weui_cell {
      margin-top: 8px;
      margin-bottom: 8px;
      .text1 {
        font-size: 15px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: rgba(255, 255, 255, 0.6);
        margin-right: 12px;
      }
      .text2 {
        font-size: 15px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: rgba(255, 255, 255, 1);
        // padding-right: 69px;
      }
      .text3 {
        font-size: 15px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: rgba(255, 255, 255, 1);
        margin-top: 5px;
      }
    }
    .line {
      width: 100%;
      height: 1px;
      background: rgba(255, 255, 255, 0.1);
      margin-bottom: 10px;
    }
  }
  .top-tab {
    // position: fixed;
    background: #292a4d;
    width: 100%;
    padding: 10px 0 10px;
    z-index: 10;
    .top-tab-scroll-wrapper {
      width: 90%;
      white-space: nowrap;
      overflow: hidden;
      .scroll-content {
        display: inline-block;
      }
      .top-tab-item {
        width: 90px;
        display: inline-block;
        padding: 0 10px;
      }
    }
    .weui_cell_primary {
      position: relative;
      padding: 4px 0;
      &.active1 {
        .title {
          font-size: 14px;
          color: rgba(69, 109, 230, 1);
        }
        .line {
          opacity: 1;
        }
      }
      .title {
        font-size: 14px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: rgba(255, 255, 255, 1);
        text-align: center;
        white-space: nowrap;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 2px;
        img {
          width: 14px;
          height: 14px;
        }
      }
      .line {
        width: 20px;
        height: 3px;
        background: rgba(69, 109, 230, 1);
        opacity: 0;
        transition: 0.3s all ease;
        margin: 0 auto;
      }
    }
  }
  .flex {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 12px;
    .box {
      min-width: 90px;
      height: 28px;
      border-radius: 2px;
      font-size: 14px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: rgba(255, 255, 255, 1);
      padding: 0 5px;
      padding-top: 0.8vh;
      /*line-height: 28px;*/
      text-align: center;
      /*display: flex;*/
      /*align-items: center;*/
      /*justify-content: center;*/
      margin: 0 17px;
      background: transparent;
      transition: 0.5s all ease-in-out;
      &.active1 {
        background: rgba(69, 109, 230, 1);
      }
    }
  }
  .content-box {
    position: relative;
    /*padding: 10px 16px;*/
    /*height: calc(100vh - 400px);*/
    height: 100vh;
    // overflow: hidden;
    background: #1f2037;
    /*overflow-y: auto;*/
    .not-content {
      width: 100%;
      display: flex;
      justify-content: center;
      align-items: center;
      flex-direction: column;
      padding-top: 40px;
      text-align: center;
      img {
        width: 64px;
        height: 64px;
        margin-left: 20px;
      }
      .title {
        margin: 8px auto;
        width: 126px;
        height: 40px;
        font-size: 14px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: rgba(158, 198, 251, 1);
        line-height: 20px;
        text-align: center;
      }
    }
    .mescroll {
      // position: fixed;
      padding: 10px 16px;
      box-sizing: border-box;
      top: 120px;
      bottom: 1px;
      height: 100%;
      /*background-color: #22233f;*/
    }
    .finnanceBox {
      padding: 0 10px !important;
    }
    .card {
      border-radius: 4px;
      background: #292a4d;
      margin-bottom: 12px;
      position: relative;
      transition: 0.2s all ease-in-out;
      &.active1 {
        background: #383a69;
      }
      // padding: 5px 10px;
      .cardTitle {
        font-size: 17px;
        padding: 8px;
        color: white;
        .title {
          overflow: hidden;
          text-overflow: ellipsis;
          display: -webkit-box;
          -webkit-line-clamp: 1;
          -webkit-box-orient: vertical;
        }
      }
      .cardTitle2 {
        color: rgba(255, 255, 255, 0.5);
        font-size: 14px;
        padding: 0px 8px 8px;
      }
      .line {
        height: 1px;
        width: 100%;
        background: #ffffff;
        opacity: 0.1;
      }
      .cardBottom {
        color: rgba(255, 255, 255, 0.5);
        font-size: 15px;
        padding: 8px;
        .title {
          overflow: hidden;
          text-overflow: ellipsis;
          display: -webkit-box;
          -webkit-line-clamp: 1;
          -webkit-box-orient: vertical;
        }
      }
      .cardRunTitle {
        font-size: 16px;
        padding: 8px 10px;
        overflow: hidden;
        border-top-left-radius: 0.1067rem;
        color: white;
        span {
          margin-left: 10px;
        }
      }
      .imgIcon {
        width: 169px;
        height: 22px;
        margin-left: 50%;
        transform: translateX(-50%);
        position: absolute;
        bottom: -15px;
        z-index: 100;
        img {
          width: 100%;
          height: 100%;
        }
      }
      .run1 {
        border-left: 2px solid #ffffff;
      }
      .run2 {
        border-left: 2px solid #456de6;
      }
      .run3 {
        border-left: 2px solid #4fdbe5;
      }
      .run4 {
        border-left: 2px solid #dd2306;
      }
      .run5 {
        border-left: 2px solid #dd9710;
      }
    }

    .replace-card {
      .cardTitle {
        display: flex;
        justify-content: space-between;
        .cardTitle-label {
          font-size: 14px;
          margin-right: 8px;
          padding: 0 6px 1px;
          color: #fff;
          border: 1px solid #456de6;
          border-radius: 2px;
        }
        .cardTitle-tip {
          margin-right: 8px;
          font-size: 14px;
          &.status {
            color: #dd9710;
          }
          &.status {
            color: #456de6;
          }
          &.status1,
          &.status4 {
            color: #4fa8e7;
          }
          &.status3 {
            color: #456de6;
          }
          &.status5 {
            color: #dd9710;
          }
          &.status9,
          &.status7 {
            color: #dd9710;
          }
        }
      }
      .cardBottom {
        .cardBottom-item {
          display: flex;
          margin: 6px 0;
          .item-key {
            flex: none;
            width: 80px;
          }

          .item-handle {
            display: flex;
            justify-content: space-between;
            // color: #fff;

            .handle-btn {
              margin-left: 8px;
              flex: none;
            }
            .btn {
              color: #fff;
              font-size: 14px;
              background-color: #456de6;
              padding: 2px 11px 3px;
              border-radius: 12px;
            }
          }
        }
      }
    }
    .device-data-grid {
      margin: 7px 10px;
      .warning {
        color: #e6a23c;
      }
      .danger {
        color: #dd2306;
      }
    }
  }
  .showPie {
    width: 100%;
    margin-bottom: 12px;
    padding: 6px 0;
    background-color: #1f2037;
    .show-title {
      color: #fff;
      display: flex;
      justify-content: space-between;
      font-size: 16px;
      padding: 0 16px;
      .show-btn {
        font-size: 12px;
        display: flex;
        align-items: center;
      }
    }
    &.show {
      padding-bottom: 12px;
    }
    .charts-wrapper {
      // height: 300px;
      height: auto;
    }
    .chart-area {
      height: 300px;
      margin: 0 16px;
      background-color: #292a4d;
    }
    .charts-pagination {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 12px;
      font-size: 16px;
      color: #fff;
      margin-top: 6px;
      padding: 0 8px;
    }
  }
  .day-charts {
    color: #fff;
    font-size: 16px;
  }
  .day-charts-time {
    margin: 12px 16px;
    padding: 8px 0;
    background-color: #292a4d;
  }
  .day-charts-tip {
    font-size: 12px;
    display: flex;
    justify-content: flex-end;
    margin-bottom: 6px;
    padding: 0 8px;
    span {
      margin-left: 20px;
      position: relative;
      &::before {
        content: "";
        position: absolute;
        top: 5px;
        left: -10px;
        width: 8px;
        height: 8px;
        border-radius: 2px;
        background-color: #fff;
      }
      &.fault::before {
        background-color: #dd6031;
      }
      &.stop::before {
        background-color: #dc9610;
      }
      &.run::before {
        background-color: #456de5;
      }
      &.offline::before {
        background-color: #d2d2d2;
      }
    }
  }
  .day-charts-area {
    padding: 0 0 8px;
    margin-top: 16px;
  }
  .day-charts-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding: 0 16px;
    font-size: 14px;
    user-select: none;
    .pagination-item,
    .pagination-text {
      background-color: #292a4d;
      border-radius: 2px;
      height: 29px;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .pagination-text {
      flex: 1;
      text-align: center;
      margin: 0 2px;
    }
    .pagination-item {
      width: 30px;
    }
  }
  .date-list-read {
    margin: 16px 16px 6px;
    font-size: 14px;
    display: flex;
    justify-content: center;
    border: 1px solid #456de6;
    border-radius: 2px;
    .list-item {
      padding: 4px;
      text-align: center;
      color: #456de6;
      flex: 1;
      &.active {
        color: #fff;
        background-color: #456de6;
      }
    }
  }
  .day-charts-bottom {
    margin-top: 2px;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    padding: 0 8px;
  }
  .day-charts-history {
    text-align: center;
    font-size: 14px;
    padding: 8px;
  }
  .day-charts-body {
    display: flex;
    height: 16px;
    border-radius: 5px;
    position: relative;
    background-color: #fff;
    overflow: hidden;
    margin: 0 8px;
    .day-charts-item {
      position: absolute;
      top: 0;
      bottom: -1px;
      &.offline {
        background-color: #d2d2d2;
      }
      &.run {
        background-color: #456de5;
      }
      &.stop {
        background-color: #dc9610;
      }
      &.fault {
        background-color: #dd6031;
      }
    }
  }
  .wrapper {
    padding-bottom: 10px;
    overflow-y: auto;
    width: 100%;
    height: 100%;
    background: #151624;
  }
  .device-data {
    padding-top: 10px;
    padding-bottom: 10px;
    width: 100%;
    height: 100%;
    background: #151624;
  }
  .mescroll-area {
    height: 100%;
    padding-bottom: 32px;
    overflow: auto;
  }
}
.replace-area {
  padding: 16px;

  .newpage_work_more {
    height: 40px;
    font-size: 12px;
    line-height: 40px;
    text-align: center;
    color: #456de6;
  }
}
.newpage_work_conent {
  color: #fff;
  background: #1b1c32;
  padding: 16px;
  .early-card {
    margin-bottom: 16px;
    .early-card-title {
      color: #409eff;
      &.warning {
        color: #ffb62c;
      }
      &.error {
        color: #ff2c2c;
      }
    }
    .early-card-tip {
      display: flex;
      justify-content: flex-end;
      margin-right: -8px;
      span {
        padding: 2px 6px 4px;
        text-align: right;
        background-color: #292a4d;
        border-radius: 5px;
      }
      &.status1 {
        color: #f56c6c;
      }
      &.status3 {
        color: #409eff;
      }
      &.status5,
      &.status9 {
        color: gray;
      }
    }
    .early-card-body {
      margin: 8px 0;
    }
    .early-card-department {
      margin: 8px 0;
      color: rgba(255, 255, 255, 0.8);
    }
    .early-card-bottom {
      padding-top: 8px;
      border-top: 1px solid rgba(255, 255, 255, 0.4);
      color: rgba(255, 255, 255, 0.6);
    }
  }
  .newpage_work_more {
    height: 40px;
    font-size: 12px;
    line-height: 40px;
    text-align: center;
    color: #456de6;
  }
}
</style>
